#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：wwdj_API 
@File    ：details_data.py
@IDE     ：PyCharm 
@Author  ：我先测了
@Date    ：2024/11/28 10:56 
'''
from operate.operate_excel import Operate_Excel
from data.config_data import Config_col

# 获取测试通过数量
class Report_Details(Operate_Excel):
    def get_pass_total(self):
        row = self.get_rows()
        i = 0
        total = 0
        row_new = 1
        col = 8
        while i < (row - 1):
            # 获取执行内容
            cell_value = self.read_cell_values(row_new, col)
            row_new += 1
            i += 1
            if cell_value == 'pass':
                total += 1
        return total

    # 获取测试失败数量
    def get_fail_total(self):
        total_number = self.get_rows() - 1
        pass_number = self.get_pass_total()
        fail_number = total_number - pass_number
        return fail_number

    # 计算测试通过率
    def get_passing_rate(self):
        pass_number = self.get_pass_total()
        total_number = self.get_rows() - 1
        passing_rate = (pass_number / total_number) * 100
        return int(passing_rate)
    #获取失败接口详情
    def get_fail_details(self):
        #获取失败接口的名称+测试报告地址
        row = self.get_rows()
        i = 0
        row_new = 1
        col = 8
        url_col = 1
        name_col=0
        url_name = []
        while i < (row - 1):
            # 获取执行内容
            cell_value = self.read_cell_values(row_new, col)
            url_name_new = self.read_cell_values(row_new, url_col)
            test_name_new = self.read_cell_values(row_new, name_col)
            develop_new = self.read_cell_values(row_new, 9)
            row_new += 1
            i += 1
            if cell_value != 'pass':
                url_name.append({"url_name":url_name_new,"test_name":test_name_new,"userid":int(develop_new)})
        return url_name
if __name__ == '__main__':
    r = Report_Details()
    print(r.get_fail_details())


